/**
 * 
 *  纵向思维
 * @param {string[]} strs
 * @return {string}
 */
var longestCommonPrefix = function (strs) {

    if (!strs.length) {
        return ''
    }

    let len = strs[0].length
    for (let i = 0; i < len; i++) {
        let c = strs[0][i]
        for (let j = 1; j < strs.length; j++) {
            if (i === strs[j].length || strs[j][i] !== c) {
                return strs[0].slice(0, i)
            }
        }
    }
    return strs[0]

};

console.log(longestCommonPrefix(["flower", "flower", "flower", "flower"]))